import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: () => import('../views/Home.vue'),
    meta: { title: '首页' }
  },
  {
    path: '/container',
    name: 'Container',
    component: () => import('../views/Container.vue'),
    meta: { title: '时间容器' }
  },
  {
    path: '/evaluation',
    name: 'Evaluation',
    component: () => import('../views/Evaluation.vue'),
    meta: { title: '经验价值评估' }
  },
  {
    path: '/insights',
    name: 'Insights',
    component: () => import('../views/Insights.vue'),
    meta: { title: '有效性洞察' }
  },
  {
    path: '/container-search',
    name: 'ContainerSearch',
    component: () => import('../views/ContainerSearch.vue'),
    meta: { title: '容器搜索与分类' }
  },
  {
    path: '/mind-archive',
    name: 'MindArchive',
    component: () => import('../views/MindArchive.vue'),
    meta: { title: '思维存档' }
  },
  {
    path: '/mind-archive-library',
    name: 'MindArchiveLibrary',
    component: () => import('../views/MindArchiveLibrary.vue'),
    meta: { title: '思维存档库' }
  },
  {
    path: '/mind-archive-detail/:id',
    name: 'MindArchiveDetail',
    component: () => import('../views/MindArchiveDetail.vue'),
    meta: { title: '存档详情' }
  },
  {
    path: '/campfire',
    name: 'Campfire',
    component: () => import('../views/Campfire.vue'),
    meta: { title: '探索营地' }
  },
  {
    path: '/campfire/post/:id',
    name: 'CampfirePostDetail',
    component: () => import('../views/CampfirePostDetail.vue'),
    meta: { title: '营地帖子详情' }
  },
  {
    path: '/campfire/create',
    name: 'CampfireCreatePost',
    component: () => import('../views/CampfireCreatePost.vue'),
    meta: { title: '分享到营地' }
  },
  {
    path: '/plan-board',
    name: 'PlanBoard',
    component: () => import('../views/PlanBoard.vue'),
    meta: { title: '计划看板' }
  },
  {
    path: '/plan-detail',
    name: 'PlanDetail',
    component: () => import('../views/PlanDetail.vue'),
    meta: { title: '计划详情' }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  document.title = `${to.meta.title || '时间胶囊'} - Time Capsule`
  next()
})

export default router